﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net; 
namespace Web.Corp
{
    public partial class corpajax : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    if (Request["collect"] != null)
                    {
                        if (string.IsNullOrEmpty(User.Identity.Name))
                        {
                            Response.Write("<script>alert('请先登录，谢谢！')</script>");
                            Response.Write("success");
                        }
                    }
                    else
                    {
                        string iPop = Request["IPop"].ToString();
                        string iService = Request["IService"].ToString();
                        string iFace = Request["IFace"].ToString();
                        string iPrice = Request["IPrice"].ToString();
                        string body = Request["Body"].ToString();
                        string corpID = Request["CorpID"].ToString();
                        string username = Dns.GetHostByName(Dns.GetHostName()).AddressList[0].ToString();
                        if (!string.IsNullOrEmpty(User.Identity.Name))
                            username = User.Identity.Name;
                        if (body.Trim().Length > 10)
                        {
                            int flag = (new Model.CorpCommentData()).Insert(username,
                                corpID, body, iFace, iService, iPrice, iPop);
                            if (flag > 0)
                            {
                                Response.Write("success");
                            }
                            else
                            {
                                Response.Write("fail");
                            }

                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("fail");
                }

            }
        }
    }
}
